import React, { useEffect, useState } from 'react'
import { useSearchParams , useNavigate } from 'react-router-dom'
import api from '../../api/axios'
function Cartlist() {
  const [sp] = useSearchParams([])
  const start = sp.get('start')
  const end = sp.get('end')
  const date = sp.get('date')
  const [page, setPage] = useState(1)
  const [list, setList] = useState([])
  const Navigate = useNavigate()
  console.log(end)
  const yu=()=>{
    Navigate('/detail')
  }
  const getData = async () => {
    const res = await api.post('/api/trip/train', {
      start,
      end,
      date,
      page
    })
    console.log(res)
    const { code, data } = res.data
    // console.log(res.data)
    if (code == 200) {
      setList([...list, ...data])
    }
  }
  useEffect(() => {
    getData()
  }, [])
  return (
    <div>
      <button onClick={()=>yu()}>预订</button>
    </div>
  )
}

export default Cartlist
